package com.migration.model.migration.scripts;

import com.migration.model.migration.AbstractMigrationScript;

/**
 * 建议措施表(risk_suggestion)迁移脚本
 */
public class A014_RiskRiskSuggestionMigrationScript extends AbstractMigrationScript {

    /**
     * 构造函数，初始化迁移配置
     */
    public A014_RiskRiskSuggestionMigrationScript() {
        super(
            "risk_suggestion",
            "建议措施数据迁移",
            "ra_advise_measures",
            "risk_suggestion",
            14
        );
    }

    /**
     * 生成迁移数据的SQL
     *
     * @return 迁移数据的SQL
     */
    @Override
    protected String generateMigrationSql() {
        return "INSERT INTO risk_suggestion (\n" +
                "    id,\n" +
                "    tenant_id,\n" +
                "    department_id,\n" +
                "    suggestion_desc,\n" +
                "    pfd,\n" +
                "    suggestion_type,\n" +
                "    responsible_person,\n" +
                "    completion_date,\n" +
                "    priority,\n" +
                "    accident_chains_status,\n" +
                "    accident_chains_num,\n" +
                "    create_time,\n" +
                "    create_by,\n" +
                "    update_time,\n" +
                "    update_by,\n" +
                "    is_del\n" +
                ")\n" +
                "SELECT\n" +
                "    id,\n" +
                "    1 as tenant_id,\n" +
                "    tenant_id AS department_id,\n" +
                "    advise_desc,\n" +
                "    pfd,\n" +
                "    advise_type,\n" +
                "    duty_officer,\n" +
                "    DATE_FORMAT(finish_date, '%Y-%m-%d'),\n" +
                "    priority,\n" +
                "    0 AS accident_chains_status,\n" +
                "    0 AS accident_chains_num,\n" +
                "    DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s'),\n" +
                "    1,\n" +
                "    DATE_FORMAT(update_time, '%Y-%m-%d %H:%i:%s'),\n" +
                "    1,\n" +
                "    is_del\n" +
                "FROM risk_lunnan_test.ra_advise_measures;";
    }

}
